$app = {
	panelStack : [ 'default-panel', 'expertise-panel', 'services-panel',
			'career-panel', 'contactus-panel' ],
	showPanel : function(id) {
		for ( var i = 0; i < $app.panelStack.length; i++) {
			var panel = $app.panelStack[i];
			if (panel === id) {
				$('#' + panel).slideDown();
			} else {
				$('#' + panel).slideUp();
			}
		}
	},
	post : function(arg) {
		$.ajax({
			url : arg.url,
			type : 'POST',
			data : arg.data,
			success : arg.success,
			error : arg.error
		});
	},
	validEmail : function(input) {
		var pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		return pattern.test(input);
	},
	validPhone : function(input) {
		var pattern = /^(?:\+?[0-9]*[-. ]?)?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
		return pattern.test(input);
	},
	validate : function(form) {
		var isValid = true;
		var requiredInputFields = $(form).find('input.required');
		var requiredSelectFields = $(form).find('select.required');
		var emailFields = $(form).find('input.email');
		var phoneFields = $(form).find('input.phone');
		requiredInputFields.removeClass('ui-state-error');
		requiredInputFields.each(function() {
			if ($(this).val().length == 0) {
				$(this).addClass('ui-state-error').focus();
				isValid = false;
				return;
			}
		});
		requiredSelectFields.each(function() {
			if ($(this).val().length == 0) {
				$(this).addClass('ui-state-error').focus();
				isValid = false;
				return;
			}
		});
		emailFields.each(function() {
			if (!$app.validEmail($(this).val())) {
				$(this).addClass('ui-state-error').focus();
				isValid = false;
				return;
			}
		});
		phoneFields.each(function() {
			if (!$app.validPhone($(this).val())) {
				$(this).addClass('ui-state-error').focus();
				isValid = false;
				return;
			}
		});
		return isValid;
	}
};
$(document).ready(function(){
	$('blockquote>code:even').css('background-color', '#ddd');
});
